﻿using System;
using SimpleOrmCFPC.Core.RequestsComputer.Dialects;
using SimpleOrmCFPC.upgrade;

namespace SimpleOrmCFPC.Core.RequestsComputer
{
    public class CreateTableRequestComputer
    {
        private TableDialect tableDialect;
        private SchemaFromTypeExtractor typeExtractor;

        public CreateTableRequestComputer(TableDialect tableDialect, SchemaFromTypeExtractor typeExtractor)
        {
            this.tableDialect = tableDialect;
            this.typeExtractor = typeExtractor;
        }

        public String ComputeRequestForCreateTable<T>()
        {
            var table = typeExtractor.Extract<T>();
            return tableDialect.GenerateCreateTableRequest(table);
        }

        public String ComputeRequestForCreateTable(TableMapping tableMapping)
        {
            return tableDialect.GenerateCreateTableRequest(tableMapping);
        }
    }
}